﻿Imports System.Activities
Imports Microsoft.Xrm.Sdk
Imports Microsoft.Xrm.Sdk.Workflow
Namespace punycodeConverter
    Public Class toPunycode
        Inherits CodeActivity
        Private m_punycode As System.Activities.OutArgument(Of String)
        Private m_idn As System.Activities.InArgument(Of String)

        <Output("PunycodeString")> _
       <[Default]("")> _
        Public Property PunyOutput() As OutArgument(Of String)
            Get
                Return m_punycode
            End Get
            Set(ByVal value As OutArgument(Of String))
                m_punycode = value
            End Set
        End Property
        <Input("IDNString")> _
       <[Default]("")> _
        Public Property IDNInput() As InArgument(Of String)
            Get
                Return m_idn
            End Get
            Set(ByVal value As InArgument(Of String))
                m_idn = value
            End Set
        End Property
        Protected Overrides Sub Execute(ByVal context As System.Activities.CodeActivityContext)
            Dim IDN As New System.Globalization.IdnMapping
            PunyOutput.Set(context, IDN.GetAscii(IDNInput.[Get](Of String)(context)))
        End Sub
    End Class
    Public Class toIDN
        Inherits CodeActivity
        Private m_punycode As System.Activities.InArgument(Of String)
        Private m_idn As System.Activities.OutArgument(Of String)

        <Input("PunycodeString")> _
       <[Default]("")> _
        Public Property PunyInput() As InArgument(Of String)
            Get
                Return m_punycode
            End Get
            Set(ByVal value As InArgument(Of String))
                m_punycode = value
            End Set
        End Property
        <Output("IDNString")> _
       <[Default]("")> _
        Public Property IDNOutput() As OutArgument(Of String)
            Get
                Return m_idn
            End Get
            Set(ByVal value As OutArgument(Of String))
                m_idn = value
            End Set
        End Property
        Protected Overrides Sub Execute(ByVal context As System.Activities.CodeActivityContext)
            Dim IDN As New System.Globalization.IdnMapping
            IDNOutput.Set(context, IDN.GetUnicode(PunyInput.[Get](Of String)(context)))
        End Sub
    End Class
End Namespace